﻿using System;
using System.Threading;
using System.Windows.Threading;

namespace MadMediaManager.WPFSupport.Interfaces.Services.Threading
{
    public interface IDispatcher
    {
        Thread Thread { get; }
        bool HasShutdownStarted { get; }
        bool HasShutdownFinished { get; }
        IDispatcherHooks Hooks { get; }

        bool CheckAccess();
        void VerifyAccess();
        void BeginInvokeShutdown(DispatcherPriority priority);
        void InvokeShutdown();
        IDispatcherOperation BeginInvoke(DispatcherPriority priority, Delegate method);
        IDispatcherOperation BeginInvoke(DispatcherPriority priority, Delegate method, object arg);
        IDispatcherOperation BeginInvoke(DispatcherPriority priority, Delegate method, object arg, params object[] args);
        IDispatcherOperation BeginInvoke(Delegate method, params object[] args);
        IDispatcherOperation BeginInvoke(Delegate method, DispatcherPriority priority, params object[] args);

        object Invoke(DispatcherPriority priority, Delegate method);
        object Invoke(DispatcherPriority priority, Delegate method, object arg);
        object Invoke(DispatcherPriority priority, Delegate method, object arg, params object[] args);
        object Invoke(DispatcherPriority priority, TimeSpan timeout, Delegate method);
        object Invoke(DispatcherPriority priority, TimeSpan timeout, Delegate method, object arg);
        object Invoke(DispatcherPriority priority, TimeSpan timeout, Delegate method, object arg, params object[] args);
        object Invoke(Delegate method, params object[] args);
        object Invoke(Delegate method, DispatcherPriority priority, params object[] args);
        object Invoke(Delegate method, TimeSpan timeout, params object[] args);
        object Invoke(Delegate method, TimeSpan timeout, DispatcherPriority priority, params object[] args);

        DispatcherProcessingDisabled DisableProcessing();

        event EventHandler ShutdownStarted;
        event EventHandler ShutdownFinished;
        event DispatcherUnhandledExceptionFilterEventHandler UnhandledExceptionFilter;
        event DispatcherUnhandledExceptionEventHandler UnhandledException;
    }
}